import 'package:flutter/material.dart';
import 'package:flutter_rfid_dmo/rfid/rfid_connection.dart';

class HightRfidPage extends StatefulWidget {
  const HightRfidPage({super.key});

  @override
  State<HightRfidPage> createState() => _HightRfidPageState();
}

class _HightRfidPageState extends State<HightRfidPage> {
  final RFIDConnection _rfidService = RFIDConnection();

  _rfidSearch() {
    _rfidService.readRFIDCard();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          // 顶部蓝色栏
          Container(
            color: const Color(0xFF3386F4),
            child: Row(
              children: [
                Container(
                  width: 70,
                  height: 40,
                  alignment: Alignment.center,
                  decoration: const BoxDecoration(
                    border: Border(
                      right: BorderSide(color: Colors.white, width: 1),
                    ),
                  ),
                  child: const Text(
                    '序号',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 28,
                    ),
                  ),
                ),
                Expanded(
                  child: Container(
                    height: 40,
                    alignment: Alignment.center,
                    child: const Text(
                      'UID',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 32,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          // 提示文字
          Padding(
            padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
            child: Text(
              '请点击 读取二维码按钮 进行操作',
              style: TextStyle(
                color: Colors.grey[700],
                fontSize: 26,
              ),
              textAlign: TextAlign.center,
            ),
          ),
          // 空白区域
          Expanded(child: Container()),
          // 底部按钮
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: SizedBox(
              width: double.infinity,
              height: 70,
              child: OutlinedButton(
                style: OutlinedButton.styleFrom(
                  backgroundColor: const Color(0xFFF8F8F8),
                  side: const BorderSide(color: Colors.cyan, width: 2),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(12),
                  ),
                ),
                onPressed: _rfidSearch,
                child: const Text(
                  '高频RFID 寻卡',
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 28,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
